﻿@model Model.AppUserList
@{
    ViewBag.Title = "LocationInfo";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#sWarehHuseId').combobox('setValue', '0');
            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenLOCATIONID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加货位信息', function () {
                HandleData.ClearForm('location');
                $('#txtLocationCode').attr("readonly", false);
                $('#cellNo').combobox('setValue', '无');
                $('#warehHuseId').combobox('setValue', '0');
                $('#LocationType').combobox('setValue', '存储货位');
                $('#txtTier').val('0');
                $('#txtVolume').val('0');
                $('#txtColumns').val('0');



            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        HandleDom.ClassTriggerClick("icon-Reload", function () {
            InitGrid();
        });

        HandleDom.ClassTriggerClick("icon-exporter", function () {
            var form = $('#query');
            form.form('submit', {
                url: '@Url.Content("~/LocationInfo/ExportExcelLocation")',
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        layer.alert('执行成功!', 9);
                    } else {
                        layer.msg(data.msg, 2);
                    }
                }
            });

        });


        //导入货位信息
        function ImpotExcel() {
            var form = $('#import');
            form.form('submit', {
                url: '@Url.Content("~/LocationInfo/ImportLocation")',
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        layer.alert('导入成功!', 9);
                        $('#btnExecl').show();
                        InitGrid();
                    } else {
                        layer.msg(data.msg, 1);
                    }
                }
            });
        }


        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑货位信息', function () {
                $('#txtLocationCode').val(row.LOCATIONCODE);
                $('#txtLocationCode').attr("readonly", true);
                HandleData.SetValueComboBox('LocationType', row.LOCATIONTYPE);
                HandleData.SetValueComboBox('warehHuseId', row.WAREHOUSEID);
                HandleData.SetValueComboBox('cellNo', row.CELLNO);
                $('#txtArea').val(row.AREA);
                $('#txtGOODSRACK').val(row.GOODSRACK);
                $('#txtTier').val(row.TIER);
                $('#txtColumns').val(row.COLUMNS);
                $('#txtRoadWay').val(row.ROADWAY);
                $('#txtVolume').val(row.VOLUME);
                $('#txtRemark').val(row.REMARK);
                $('#hiddenLOCATIONID').val(row.LOCATIONID);

            });
        }

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "LocationInfo")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }

        function InitGrid() {
            var txtSlocationCode = $('#txtSlocationCode').val();
            var sLocationType = $('#sLocationType').combobox('getValue');
            var sWarehHuseId = $('#sWarehHuseId').combobox('getValue');
            var txtSArea = $('#txtSArea').val();
            var txtSRoadWay = $('#txtSRoadWay').val();
            var txtStatus = $('#status').combobox('getValue');

            queryParams = {
                locationCode: txtSlocationCode,
                warehHuseId: sWarehHuseId,
                locationType: sLocationType,
                sArea: txtSArea,
                roadWay: txtSRoadWay,
                status: txtStatus
            }
            HandleData.InitDataGrid('dg', '/LocationInfo/InitJsonResult', 'toolbar', queryParams, 'LOCATIONID', true, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>货位编号:
                    </td>
                    <td>
                        <input id="txtSlocationCode" name="txtSlocationCode" style="width: 154px" />
                    </td>
                    <td>货位类型:
                    </td>
                    <td>
                        <select id="sLocationType" class="easyui-combobox" name="sLocationType" style="width: 154px;">
                            <option value="">--全部--</option>
                            <option value="逻辑货位">逻辑货位</option>
                            <option value="存储货位">存储货位</option>
                        </select>
                    </td>
                    <td>仓库:
                    </td>
                    <td>
                        <input id="sWarehHuseId" class="easyui-combobox" name="sWarehHuseId" style="width: 155px;" data-options="required:true,valueField:'WAREHOUSEID',textField:'WAREHOUSENAME',url:'@Url.Action("GetWarehouseList", "LocationInfo", new { isDefault = true, defaultValue = "请选择仓库" })',editable:false">
                    </td>
                </tr>
                <tr>
                    <td>区域:
                    </td>
                    <td>
                        <input id="txtSArea" name="txtSArea" style="width: 154px" />
                    </td>
                    <td>巷道:
                    </td>
                    <td>
                        <input id="txtSRoadWay" name="txtSRoadWay" style="width: 154px" />
                    </td>
                    <td>状态:
                    </td>
                    <td>
                        <select id="status" class="easyui-combobox" name="status" style="width: 154px;">
                            <option value="">--全部--</option>
                            <option value="0">失效</option>
                            <option value="1">生效</option>
                        </select>
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>
                </tr>

            </table>
        </form>
        <form id="import" method="post" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>
                        <input id="FileUpload" type="file" name="files" style="width: 250px; height: 24px; background: White"
                            class="easyui-validatebox" />
                        <a id="btnGet" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="ImpotExcel()">导入</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="货位信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'LOCATIONID',width:30">货位ID</th>
                    <th data-options="field:'LOCATIONCODE',width:50">货位编码</th>
                    <th data-options="field:'LOCATIONTYPE',width:50">货位类型</th>
                    <th data-options="field:'WAREHOUSENAME',width:50">仓库</th>
                    <th data-options="field:'CELLNO',width:50">库位</th>
                    <th data-options="field:'GOODSRACK',width:50">货架</th>
                    <th data-options="field:'TIER',width:30">层</th>
                    <th data-options="field:'COLUMNS',width:30">列</th>
                    <th data-options="field:'AREA',width:30">区域</th>
                    <th data-options="field:'ROADWAY',width:30">巷道</th>
                    <th data-options="field:'VOLUME',width:30">体积</th>
                    <th data-options="field:'CREATER',width:50">创建人</th>
                    <th data-options="field:'CREATEDATE',width:100,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">创建时间</th>
                    <th data-options="field:'REMARK',width:100">备注</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 250px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>货位编码:
                    </td>
                    <td>
                        <input id="hiddenLOCATIONID" name="hiddenLOCATIONID" type="hidden" />
                        <input id="hiddenLocationCode" name="hiddenLocationCode" type="hidden" />
                        <input id="txtLocationCode" name="txtLocationCode" maxlength="20" style="width: 154px" class="easyui-validatebox" data-options="required:true" />
                    </td>
                    <td>货位类型:
                    </td>
                    <td colspan="2">
                        <select id="LocationType" class="easyui-combobox" name="LocationType" style="width: 154px;">
                            <option value="存储货位">存储货位</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>货架:
                    </td>
                    <td>
                        <input id="txtGOODSRACK" name="txtGOODSRACK" maxlength="128" style="width: 154px" />
                    </td>
                    <td>仓库：</td>
                    <td>
                        <input id="warehHuseId" class="easyui-combobox" name="warehHuseId" style="width: 155px;" data-options="required:true,valueField:'WAREHOUSEID',textField:'WAREHOUSENAME',url:'@Url.Action("GetWarehouseList", "LocationInfo", new { isDefault = true, defaultValue = "请选择仓库" })',editable:false">
                    </td>
                </tr>
                <tr>
                    <td>层:
                    </td>
                    <td>
                        <input id="txtTier" name="txtTier" maxlength="30" style="width: 154px" />
                    </td>
                    <td>列:
                    </td>
                    <td colspan="2">
                        <input id="txtColumns" name="txtColumns" maxlength="30" style="width: 154px" />
                    </td>
                </tr>
                <tr>
                    <td>区域:
                    </td>
                    <td>
                        <input id="txtArea" name="txtArea" maxlength="20" style="width: 154px" />
                    </td>
                    <td>巷道:
                    </td>
                    <td colspan="2">
                        <input id="txtRoadWay" name="txtRoadWay" maxlength="20" style="width: 154px" />
                    </td>
                </tr>
                <tr>
                    <td>体积:
                    </td>
                    <td>
                        <input id="txtVolume" name="txtVolume" maxlength="20" style="width: 154px" />
                    </td>
                    <td>库位:
                    </td>
                    <td colspan="2">
                        <input id="cellNo" class="easyui-combobox" name="cellNo" style="width: 155px;" data-options="required:true,valueField:'CELLNO',textField:'CELLNO',url:'@Url.Action("CellNoList", "BaseData", new { })',editable:false">
                    </td>
                </tr>
                <tr>
                    <td>备注:
                    </td>
                    <td colspan="4">
                        <input id="txtRemark" name="txtRemark" maxlength="255" style="width: 520px" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(false)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =true },
              new FunctionModule(){Name = "AllAdd",IsEnable =true },
              
              
            }
        }
    }
})

</body>

